﻿using Microsoft.Extensions.Configuration;
using SOEI.TxmApi.Extend.Core;
using System;
using System.Collections.Generic;
using System.Text;

namespace SOEI.Solution.Helper
{
    public class JsonFile
    {
        private static IConfigurationRoot ReadJsonFile(string pFileName = "TxmSetting.json")
        {
            return new ConfigurationBuilder().AddJsonFile(pFileName).Build();
        }

        private static TXMSetting _TxmSettings;

        public static TXMSetting TxmSettings
        {
            get
            {
                if (_TxmSettings == null)
                {
                    var vConfig = ReadJsonFile();

                    _TxmSettings = new TXMSetting()
                    {
                        ApiUrl = vConfig["ApiUrl"],
                        Token = vConfig["Token"],
                        SoapUserName = vConfig["SoapUserName"],
                        SoapPassword = vConfig["SoapPassword"]
                    };
                }
                return _TxmSettings;
            }
        }
    }
}